<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2023/5/29
 * Time: 10:37
 */

namespace app\common\validate;
use think\Validate;

class Car extends Validate
{
    /**
     * 验证规则
     */
    protected $rule = [
        'license_plate' => 'require|unique:car',
        'IMEI' => 'require',
        'driver_id' => 'require',


    ];
    protected function checkMobile($value,$rule,$data)
    {
        $rule = '/^0?(13|14|15|17|18)[0-9]{9}$/';
        $result = preg_match($rule, $value);
        if (!$result) {
            return false;
        }
        return true;
    }
    /**
     * 提示消息
     */
    protected $message = [
        'license_plate.require' => '车牌号不能为空',
        'license_plate.unique' => '车牌号已存在',
        'IMEI.require' => '移动设备识别码不能为空',
        'driver_id.require' => '司机不能为空',
    ];

    /**
     * 字段描述
     */
    protected $field = [
    ];

    /**
     * 验证场景
     */
    protected $scene = [
        /*'add'  => ['username',  'nickname', 'password'],
        'edit' => ['username', 'nickname', 'password'],*/
    ];
}